import 'package:wanxiang_app/generated/json/base/json_convert_content.dart';
import 'package:wanxiang_app/bean/banner_entity.dart';

BannerEntity $BannerEntityFromJson(Map<String, dynamic> json) {
  final BannerEntity bannerEntity = BannerEntity();
  final int? code = jsonConvert.convert<int>(json['code']);
  if (code != null) {
    bannerEntity.code = code;
  }
  final String? msg = jsonConvert.convert<String>(json['msg']);
  if (msg != null) {
    bannerEntity.msg = msg;
  }
  final List<BannerData>? data = (json['data'] as List<dynamic>?)?.map(
          (e) => jsonConvert.convert<BannerData>(e) as BannerData).toList();
  if (data != null) {
    bannerEntity.data = data;
  }
  return bannerEntity;
}

Map<String, dynamic> $BannerEntityToJson(BannerEntity entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['code'] = entity.code;
  data['msg'] = entity.msg;
  data['data'] = entity.data.map((v) => v.toJson()).toList();
  return data;
}

extension BannerEntityExtension on BannerEntity {
  BannerEntity copyWith({
    int? code,
    String? msg,
    List<BannerData>? data,
  }) {
    return BannerEntity()
      ..code = code ?? this.code
      ..msg = msg ?? this.msg
      ..data = data ?? this.data;
  }
}

BannerData $BannerDataFromJson(Map<String, dynamic> json) {
  final BannerData bannerData = BannerData();
  final String? name = jsonConvert.convert<String>(json['name']);
  if (name != null) {
    bannerData.name = name;
  }
  final String? url = jsonConvert.convert<String>(json['url']);
  if (url != null) {
    bannerData.url = url;
  }
  return bannerData;
}

Map<String, dynamic> $BannerDataToJson(BannerData entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['name'] = entity.name;
  data['url'] = entity.url;
  return data;
}

extension BannerDataExtension on BannerData {
  BannerData copyWith({
    String? name,
    String? url,
  }) {
    return BannerData()
      ..name = name ?? this.name
      ..url = url ?? this.url;
  }
}